/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.servientrega.session;

import com.servientrega.dao.ServientregaDAO;
import com.servientrega.service.Shipment;
import javax.jws.WebMethod;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.ejb.Stateless;
import javax.jws.WebParam;
import javax.sql.DataSource;

/**
 *
 * @author allan
 */
@WebService(serviceName = "ShipmentService")
@Stateless()
public class ShipmentService {

    private ServientregaDAO dao;
    @Resource(mappedName = "jdbc/Servientrega", type = DataSource.class)
    DataSource dsOMS;

    @PostConstruct
    void postConstruct() {
        dao = new ServientregaDAO(dsOMS);
    }

    /** This is a sample web service operation */
    @WebMethod(operationName = "CreateShipment")
    public boolean CreateShipment(@WebParam(name = "shipment") Shipment shipment) throws Exception {
        boolean item = false;
        try {

            item = dao.CreateShipment(shipment);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }
        return item;
    }
    
    /**
     * GetShipmentStatus
     * @param idOrder
     * @return
     * @throws Exception 
     */
    @WebMethod(operationName = "GetShipmentStatus")
    public String GetShipmentStatus(@WebParam(name = "idOrder") long idOrder) throws Exception {
        String item = "";
        try {

            item = dao.getShipmenStatus(idOrder);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }
        return item;
    }
}
